import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo_k/view/custom_app_bar.dart';

import '../model/counter_provider.dart';
import '../widget/inherited_widget_test.dart';

class InheritedPage extends StatefulWidget {
  static const String routeName = '/inherited_page';
  const InheritedPage({super.key});

  @override
  State<InheritedPage> createState() => _InheritedPageState();
}

class _InheritedPageState extends State<InheritedPage> {
  int _count = 0;
  int _contTwo = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        title: 'inheritedWidgetTest',
      ),
      body: Column(
        children: [
          CounterProvider(
            count: _count,
            child: CounterDisplay(),
          ),
          Text('$_contTwo'),
        ],
      ),
      floatingActionButton: Column(
        children: [
          FloatingActionButton(
            onPressed: _incrementCounter,
            child: const Icon(Icons.add),
          ),
          FloatingActionButton(
            onPressed: _incrementCounterTwo,
            child: const Icon(Icons.exposure_minus_1),
          ),
        ],
      ),
    );
  }

  void _incrementCounter() {
    setState(
      () {
        _count++;
      },
    );
  }

  void _incrementCounterTwo() {
    setState(
      () {
        _contTwo++;
      },
    );
  }
}
